Conditions | 1 |
Paths | 1 |
Total Lines | 54 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | var path = require('path'); |
||
21 | }).then(function() { |
||
22 | var nextCommand = ssh.mkdir('/var/www/auth.local/src/'); |
||
23 | // @see: https://github.com/steelbrain/node-ssh/blob/master/src/index.js |
||
24 | nextCommand.then( function(){ |
||
25 | ssh.exec('rm', ['-rf', 'public'], { cwd: '/var/www/auth.local', stream: 'both' }).then( function(both){ |
||
26 | ssh.exec('ln', ['-s','web','public'], { cwd: '/var/www/auth.local', stream: 'both' }).then( function(both){ |
||
27 | ssh.dispose(); |
||
28 | process.stdout.write(chalk.gray(emoji.emojify("Prepare dir remote completed.\n"))); |
||
29 | |||
30 | process.stdout.write(chalk.gray(emoji.emojify("Start rsync src.\n"))); |
||
31 | |||
32 | rsync({ |
||
33 | src: "./applications/externalLogin/", |
||
34 | dest: 'developer@' + server_name + ':/var/www/auth.local/', |
||
35 | ssh: true, |
||
36 | privateKey: './server/plays/ssh/developer.key', |
||
37 | port: 2222, |
||
38 | exclude: [ 'test', '.DS_Store', 'phpunit.xml', 'README.md', 'vendor' ], |
||
39 | recursive: true, |
||
40 | deleteAll: false //senno elimina log! |
||
41 | },function (error,stdout,stderr,cmd) { |
||
42 | if ( error ) { |
||
43 | process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] "+'CMD: '+cmd+"\n"))); |
||
44 | process.stderr.write(chalk.red(error.message+"\n")); |
||
45 | process.exit(1); |
||
46 | } |
||
47 | }); |
||
48 | |||
49 | process.stdout.write(chalk.gray(emoji.emojify("Avvio composer install\n"))); |
||
50 | |||
51 | ssh.connect({ |
||
52 | host: server_name, |
||
53 | username: 'developer', |
||
54 | privateKey: './server/plays/ssh/developer.key', |
||
55 | port: 2222 |
||
56 | }).then(function() { |
||
57 | ssh.exec('composer', ['install', '--no-dev', '--optimize-autoloader', '--no-interaction', '--no-progress', '--no-scripts'], { cwd: '/var/www/auth.local/', stream: 'both' }).then(function(both) { |
||
58 | process.stdout.write(chalk.gray(emoji.emojify(both.stdout+"\n"))); |
||
59 | if ( both.code === 0 ){ |
||
60 | process.stdout.write(chalk.gray(emoji.emojify(both.stderr+"\n"))); |
||
61 | } else { |
||
62 | process.stderr.write(chalk.bgRed.white(emoji.emojify("[:heavy_multiplication_x: ] Errore composer\n"))); |
||
63 | process.stderr.write(chalk.red(both.stderr+"\n")); |
||
64 | process.exit(1); |
||
65 | } |
||
66 | process.stdout.write(chalk.bgGreen.black(emoji.emojify('[:heavy_check_mark: ] Deploy COMPLETED.' + "\n"))); |
||
67 | ssh.dispose(); |
||
68 | }); |
||
69 | }); |
||
70 | |||
71 | }); |
||
72 | }); |
||
73 | }); |
||
74 | }); |
||
75 |